package com.example.administrator.myapplication.service;


import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.util.Log;
import android.widget.Toast;

/**
 * Created by Administrator on 2017/8/2 0002.
 */

public final class WeChatDatabaseHelper extends SQLiteOpenHelper {
    private static final String TAG = "WeChatDatabaseHelper";
    private Context mContext;
    public final String TableName = "user_table"; //用户表名称
    private final static String DATABASE_NAME = "my_wechat.db"; //数据库名称

    private String ACCOUNT_TABLE_CREATE =
            "CREATE TABLE IF NOT EXISTS "+TableName+"(_id integer primary key autoincrement,"
            +"username text,"
            +"password text,"
            +"landing_status boolean,"
            +"last_sync_time text,"
            +"iphone_imei text);";

    public WeChatDatabaseHelper(Context context){
        super(context,DATABASE_NAME,null,1);
        mContext = context;
    }

    /**
     * 记住，此方法只在第一次创建数据库的时候被调用，以后如果想要添加数据表就必须在onUpgrade()中编写代码
     * 并更改数据库的版本号
     */
    @Override
    public void onCreate(SQLiteDatabase db) {

       db.execSQL(ACCOUNT_TABLE_CREATE);
        Log.i(TAG, "onCreate: 基础表初始化创建成功！");
    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
        Log.i(TAG, "onUpgrade: 数据库更新了！");
    }

    @Override
    public void onOpen(SQLiteDatabase db) {
        super.onOpen(db);
    }

}
